memshr: fix off-by-one in filename size check
authorMatthew Daley <mattd@bugfuzz.com>
Thu, 28 Nov 2013 10:17:11 +0000 (23:17 +1300)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 29 Nov 2013 10:29:04 +0000 (10:29 +0000)
Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/memshr/shm.c

index c925cf26ac0e5b5c2a932e8121f9731491922350..30975dcbf69ef1a1e8c26d58c30953163e931d66 100644 (file)
@@ -217,9 +217,9 @@ uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs)
         DPRINTF("No space in vbds table.\n");
         return 0;
     }
-    if(strlen(file) > MAX_NAME_LEN)
+    if(strlen(file) > MAX_NAME_LEN - 1)
     {
-        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN);
+        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN - 1);
         return 0; 
     }
     /* Init the entry */